//
//  DeviceInfoCell.m
//  StormWatch
//
//  Created by Hero on 2024/8/31.
//

#import "DeviceInfoCell.h"
#import "DeviceInfoModel.h"
@implementation DeviceInfoCell

- (void)setModel:(DeviceInfoModel *)model {
    [super setModel:model];
    self.nameLab.text = model.per.name;
    self.macAddress.text = model.per.macAddress;
    
    self.eleLab.text = [NSString stringWithFormat:@"%ld%%",model.electric];
    
    if (model.electric < 25) {
        self.eleImageView.image = U_imageNamed(@"battery_low");
    }else if (model.electric >= 25 && model.electric < 35) {
        self.eleImageView.image = U_imageNamed(@"battery_25");
    }else if (model.electric >= 35 && model.electric < 45) {
        self.eleImageView.image = U_imageNamed(@"battery_35");
    }else if (model.electric >= 45 && model.electric < 55) {
        self.eleImageView.image = U_imageNamed(@"battery_45");
    }else if (model.electric >= 55 && model.electric < 65) {
        self.eleImageView.image = U_imageNamed(@"battery_55");
    }else if (model.electric >= 65 && model.electric < 75) {
        self.eleImageView.image = U_imageNamed(@"battery_65");
    }else if (model.electric >=75 && model.electric < 85) {
        self.eleImageView.image = U_imageNamed(@"battery_75");
    }else if (model.electric >=85 && model.electric < 100) {
        self.eleImageView.image = U_imageNamed(@"battery_85");
    }else if (model.electric >= 100 ) {
        self.eleImageView.image = U_imageNamed(@"battery_100");
    }
    
    if (model.per.deviceType.intValue == 5) {
        self.icon.image = U_imageNamed(@"止鼾枕设备");
        self.eleImageView.hidden =  YES;
    }else {
        self.icon.image = U_imageNamed(@"icon_watch_style_2");
    }
    
}


- (IBAction)clickDisconnectBle:(id)sender {
    
    self.disBlock();
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
//    [self.cancelBtn setTitle:SWString(@"Remove Device") forState:0];
    
//    self.cancelBtn.layer.cornerRadius = 4;
    
//    NSMutableArray * arr = [[NSMutableArray alloc] init];
//    NSString * address = [FRQBluetoothManager shareManager].curPeripheral.macAddress;
//    for (int i = 0 ; i < 6; i ++) {
//        [arr insertObject:[address substringWithRange:NSMakeRange(i * 2, 2)] atIndex:0];
//    }
//    self.macAddress.text = [arr componentsJoinedByString:@":"];
    
  
    // Initialization code
}

@end
